package com.yuchuang.base;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.List;

@Data
@Accessors(chain = true) //可以以链的形式调用
@JsonInclude(JsonInclude.Include.NON_NULL)
/**
 *@authoe    :cy
 *@date      :13:35 2023-04-25
 *description:  @JsonInclude(JsonInclude.Include.NON_NULL)：让封装的实体类不返回为空的属性
 * @Accessors(chain = true) //可以以链的形式调用
 *return     :
**/
public class PageInfo<T>{
    @ApiModelProperty("list内容")
    private List<T> content;
    @ApiModelProperty("当前页码")
    private Integer page;
    @ApiModelProperty("单页条数")
    private Integer size;
    @ApiModelProperty("总条数")
    private Integer total;
    @ApiModelProperty("总页数")
    private Integer pages;

    public static <T> PageInfo page(List<T> t,int page,int size,int total,int pages){
        return new PageInfo().setContent(t).setPage(page).setSize(size).setTotal(total).setPages(pages);
    }
}
